package com.tinymall.common;

/**
 * @author R.Yu
 * @date 2022/3/19 12:21
 */
public class ResponseDataUtils {
    /**
     * 带实体的统一返回
     *
     * @param data     实体
     * @param <Object> 实体类型
     * @return
     */
    public static <Object> ResponseData buildSuccess(Object data) {
        return new ResponseData<Object>(ResultEnums.SUCCESS, data);
    }

    public static ResponseData buildSuccess() {
        return new ResponseData(ResultEnums.SUCCESS);
    }

    public static ResponseData buildSuccess(String msg) {
        return new ResponseData(ResultEnums.SUCCESS.getCode(), msg);
    }

    public static ResponseData buildSuccess(String code, String msg) {
        return new ResponseData(code, msg);
    }

    public static <Object> ResponseData buildSuccess(String code, String msg, Object data) {
        return new ResponseData<Object>(code, msg, data);
    }

    public static ResponseData buildSuccess(ResultEnums resultEnums) {
        return new ResponseData(resultEnums);
    }

    public static <Object> ResponseData buildError(Object data) {
        return new ResponseData<Object>(ResultEnums.ERROR, data);
    }

    public static ResponseData buildError() {
        return new ResponseData(ResultEnums.ERROR);
    }

    public static ResponseData buildError(String msg) {
        return new ResponseData(ResultEnums.ERROR.getCode(), msg);
    }

    public static ResponseData buildError(String code, String msg) {
        return new ResponseData(code, msg);
    }

    public static <Object> ResponseData buildError(String code, String msg, Object data) {
        return new ResponseData<Object>(code, msg, data);
    }

    public static ResponseData buildError(ResultEnums resultEnums) {
        return new ResponseData(resultEnums);
    }
}